package zsc.ruanc.practicaltraining.model.domain;


import javax.validation.constraints.Min;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import zsc.ruanc.practicaltraining.model.vo.createUserVo;

import java.util.Date;

/**
 * 用户表
 */
@Data
@NoArgsConstructor
public class TUser {

  @NotNull(message = "id不能为空")
  @Min(message = "id不能为小于0", value = 0)
  @ApiModelProperty(value = "id，自增主键", required = true, dataType = "int")
  private Integer id;

  @NotBlank(message = "username不能为空")
  @ApiModelProperty(value = "用户名称", required = true, dataType = "string")
  private String username;

  @NotBlank(message = "password不能为空")
  @ApiModelProperty(value = "用户密码", required = true, dataType = "string")
  @Length(message = "密码要大于6位", min = 6)
  private String password;

  @NotBlank(message = "email不能为空")
  @ApiModelProperty(value = "用户邮箱", required = true, dataType = "string")
  @Pattern(regexp = "^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.[a-zA-Z0-9]{2,6}$",message = "不满足邮箱正则表达式")
  private String email;

  @ApiModelProperty(value = "创建时间", required = false, dataType = "Date")
  private Date created;

  @ApiModelProperty(value = "用户账号是否有效", required = false, dataType = "bool")
  private Boolean valid;

  @ApiModelProperty(value = "用户头像", required = false, dataType = "string")
  private String profilePhoto;

  @ApiModelProperty(value = "生日", required = false, dataType = "Date")
  private Date birthday;

  @ApiModelProperty(value = "性别", required = false, dataType = "bool")
  private boolean sex;

  @ApiModelProperty(value = "身份", required = false, dataType = "int")
  private Integer roleId;

  @ApiModelProperty(value = "座右铭", required = false, dataType = "String")
  private String motto;

  @ApiModelProperty(value = "爱好", required = false, dataType = "String")
  private String hobby;

  public TUser(createUserVo createUserVo) {
    this.username = createUserVo.getUsername();
    this.password = createUserVo.getPassword();
    this.email = createUserVo.getEmail();
    this.created = new Date();
  }

  @ApiModelProperty(value = "发表文章的总数", required = false, dataType = "int")
  private Integer articleCount;

  @ApiModelProperty(value = "自我介绍", required = false, dataType = "int")
  private String introduce;


}
